#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    , _ref(_ix)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    void setX(int ix)
    {
        _ix = ix;
    }

    void print()
    {
        cout << "(" << _ix
             << ", " << _iy
             << ", " << _ref
             << ")" << endl;
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
    int &_ref;//引用占用一个指针大小的空间,实质：* const
};

void test()
{
    cout << "sizeof(Point) = " << sizeof(Point) << endl << endl;

    Point pt(1, 2);//pt栈对象
    cout << "pt = ";
    pt.print();

    cout << endl;
    pt.setX(100);
    cout << "pt = ";
    pt.print();
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

